package com.sj.szxy.courseschedule.constrant;


import java.util.ArrayList;
import java.util.List;

import com.sj.szxy.courseschedule.entity.Subject;
import com.sj.szxy.courseschedule.entity.course.Course;

/**
 * 
 * @author Yi Ping
 * @date 2018年3月29日 上午10:52:15 
 * @since 1.0.0
 *
 */
public class ExcludeSubjectConstraint extends Constraint {
	
	private List<Subject> excludeSubjects = new ArrayList<>();
	
	@Override
	public boolean support(Course course) {
		return !excludeSubjects.contains(course.getSubject());
	}

	@Override
	public Constraint addConstraint(Constraint newConstraint) {
		if(newConstraint instanceof ExcludeSubjectConstraint) {
			excludeSubjects.addAll(((ExcludeSubjectConstraint) newConstraint).getExcludeSubjects());
			return this;
		}
		
		return super.addConstraint(newConstraint);
	} 

	public List<Subject> getExcludeSubjects() {
		return excludeSubjects;
	}

	@Override
	public String toString() {
		return this.getClass().getSimpleName() + "@" + excludeSubjects ;
	}

	
	
	
}
